﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

using CCOMDataAccess;

public partial class Members : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        CCOMDataAccess.DataClassesDataContext db = new DataClassesDataContext();
        var members = from m in db.Users
                      join us in db.UserToSquads
                      on m.Matricule equals us.User
                      select new
                      {
                          Matricule = m.Matricule,
                          Pseudo = m.Pseudo,
                          Prename = m.Prename,
                          Name = m.Name,
                          Rank = m.Rank1.Name,
                          Squad = us.Squad1.Name,
                          Experience = m.Experience
                      };
        gdMembers.DataSource = members;

        if (SessionManager.isLogged())
            if (UserManager.getUserInfos(int.Parse(Session["UserId"].ToString())).Rank1.AdminLevel > 99)
                gdMembers.Columns[0].Visible = true;

        gdMembers.DataBind();
    }
}
